<?php include "top.php"; ?>
<script src="uploadify/swfobject.js"  language="javascript" ></script>
<script src="uploadify/jquery.uploadify.v2.1.4.min.js"  language="javascript" ></script>
<link href="uploadify/uploadify.css" rel="stylesheet" type="text/css" />
 <?php
		 $nid=make_safe($_GET["nid"]); 
		 $BigClassName=make_safe($_GET["BigClassName"]); 
		 if($nid==""){$nid=1;}
		 
		if($nid==1){$nidname="公司樣本";}
		 if($nid==2){$nidname="禮服";}
		 if($nid==3){$nidname="客戶";}
		 
		 
		?>
      <div id="top-3">
        <div id="m-text-1">
        <table border="0" cellpadding="0" cellspacing="0" class="tab-5">
   <tr>
     <td valign="top"><div class="tab-5-tit">主功能列表</div>
     <div class="m-text-2_btn"><a href="category.php?nid=<?php echo $nid;?>">作品分類管理</a></div>
     <div class="m-text-2_btn"><a href="target.php?nid=<?php echo $nid;?>" >標簽管理</a></div>
        <div class="tab-5-tit">相簿管理</div>
      
	 
	 <?php
  $n=1;

  $sql="select * from product_type_big where nid='$nid' order by orderid  ";			
	$result=mysql_query($sql);
	while ($row=mysql_fetch_object($result)){
	?>
     <div class="m-text-2_btn"><a href="working.php?nid=<?php echo $nid;?>&BigClassName=<?php echo urlencode($row->BigClassName);?>"><?php echo $row->BigClassName;?></a></div>
     <?php }?>
       </td>
   </tr>
   </table>
        </div>
        <div id="m-text-2_banner">
          <ul>
        
            <li>/ </li>
            
            <li>培豪作品管理->修改</li>
          </ul>
        </div><div id="m-text-2"></td>
   </tr>
   </table>
   
   
   
   
      <?php 
   $id=make_safe($_GET["id"]); 
   $nid=make_safe($_GET["nid"]); 
   $action=make_safe($_GET["action"]);
   
    
   $title=make_safe($_GET["title"]); 
   if($title==""){$title=make_safe($_POST["title"]);}
   
 
   
   $BigClassName=make_safe($_GET["BigClassName"]);
   if($BigClassName==""){$BigClassName=make_safe($_POST["BigClassName"]);} 
   
   
   $addtime=$data3;
   
   
  

  
   
   
   
   
   
   
   
   if($action=="xiugai"){
   $oldimages=make_safe($_POST["oldimages"]);
  $path =  "upfiles/tmp/".$_POST['ajaxf_images'];
   $type=strstr($path,'.');
   $path2 = "upfiles/".$data."1".$type;
   $type=strtolower($type); 
   
   if($type==".jpg"  or $type==".jpge" or $type==".jpeg" or $type==".gif" or $type==".doc" or $type==".xls" or $type==".bmp" or $type==".pdf" ){
	//move_uploaded_file("../upfiles/tmp/".$path,"../upfiles/".$path2);//上传图片
	copy("../".$path,"../".$path2);
	unlink("../".$path);
	
	$srcImage = "../".$path2;
			 $desc = $srcImage.'-68x68.jpg';
			 make_thumnail($srcImage,$desc ,68,68,'4');
			 
	if($oldimages!=""){@unlink("../".$oldimages);@unlink("../".$oldimages.'-68x68.jpg');}//删除旧图片
}
else
{
	$path2=$oldimages;
}
  
if($query=mysql_query("update product2 set  title='$title',BigClassName='$BigClassName',addtime='$addtime',images='$path2' where id='$id'"))

{
   echo "<script>alert('資料修改成功！');window.location.href='product2.php?BigClassName=".urlencode($BigClassName)."&title=".urlencode($title)."&nid=".$nid."&page=".$page."';</script>";
 }
 
 else
  {
   echo "<script>alert('資料修改失敗！');window.location.href='product2.php?BigClassName=".urlencode($BigClassName)."&title=".urlencode($title)."&nid=".$nid."&page=".$page."';</script>";
  }

   
    
   
  }
  
   ?>
   
   

   
   
   
   <?php 
   $id=make_safe($_GET["id"]); 
	 $sql="select * from product2 where id='$id' ";			
	 $result=mysql_query($sql);
	 while ($row=mysql_fetch_object($result)){
	 ?>
        <form name="form1" action="?action=xiugai&id=<?php echo $row->id;?>&nid=<?php echo $row->nid;?>" method="post" enctype="multipart/form-data" target="_self">
        
        <table border="0" cellpadding="0" cellspacing="0" class="m-text-2-imp">
		
		
		<tr>
            <td class="m-text-2-con2">類別：
             
             <select name="BigClassName" >
			  
			  <?php
  $n=1;

  $sql2="select * from product_type_big where nid='$nid' order by orderid  ";			
	$result2=mysql_query($sql2);
	while ($row2=mysql_fetch_object($result2)){
	?>
    
	 <option  value="<?php echo $row2->BigClassName;?>"   <?php if($row->BigClassName==$row2->BigClassName){echo "selected";}?>><?php echo $row2->BigClassName;?></option>
	
     <?php }?>
			  
                
              </select></td>
            </td>
          </tr>
          <tr>
            <td class="m-text-2-con2">相簿名稱：
             
             <select name="title" >
			  
			  <?php
  $n=1;

  $sql2="select * from product where nid='$nid' order by id  ";			
	$result2=mysql_query($sql2);
	while ($row2=mysql_fetch_object($result2)){
	?>
    
	 <option  value="<?php echo $row2->title;?>"   <?php if($row->title==$row2->title){echo "selected";}?>><?php echo $row2->title;?></option>
	
     <?php }?>
			  
                
              </select>
              </td>
            
          </tr>
		  <tr>
            <td class="m-text-2-con2">原作品：
             
			 
			 <?php
			   $aa=getimagesize("../".$row->images);
$weight=$aa["0"];////获取图片的宽
$height=$aa["1"];///获取图片的高

if($weight>=$height){$weight1=160;$height1=160*$height/$weight;}
if($height>=$weight){$height1=160;$weight1=160*$weight/$height;}
			 
			 ?>
             
			 <?php if($row->images!=""){?><img id="images_img" src="<?php echo "../".$row->images;?>" width="<?php echo $weight1;?>" height="<?php echo $height1;?>" border="0" /><?php }?>
			 
			 
			 </td>
        
          </tr>
		  
		<script language="javascript">
			$(function(){
				$(".uploadifyupload").each(function(){
					var current_id = $(this).attr('id');
					var previous_img_id = current_id + '_img';
					$(this).uploadify({
						'uploader': 'uploadify/uploadify.swf',
						'cancelImg': 'uploadify/cancel.png',
						'script': 'upload.php',
						'folder': 'files',
						'buttonText':'Choose',
						'multi': false,
						'fileExt':'*.jpg;*.jpeg;*.gif;*.png',
  						'fileDesc':'Image Files',
						'auto': true,
						'queueSizeLimit':1,
						'scriptData':{'<?php echo session_name();?>':'<?php echo session_id();?>','name':$(this).attr('name'),'responsetype':'sizeinfo'},
						'displayData': 'speed',
						'onComplete':function(event,queueID,fileObj,response,data){
							var responseObj = eval("("+response+")");
							var fileName = responseObj.name;
							$('#'+previous_img_id).attr('src','../upfiles/tmp/' + fileName);
							$('input[name=ajaxf_'+current_id+']').val(fileName);
							
						},
						'onError':function(event,queueId,fileObj,errorObj){
							alert(errorObj);
						}
					});
				});
			});
		</script>
		  <tr>
            <td class="m-text-2-con2">上傳作品：
             <input type="hidden" name="ajaxf_images" value=""/>
              <input name="images" class="uploadifyupload" id="images" type="file"  size="60"><input name="oldimages" type="hidden" value="<?php echo $row->images;?>" size="30"></td>
        
          </tr>
		  
		  
		  
		  <tr>
            <td class="m-text-2-con2"><div align="center">
              <input type="submit" name="Submit" value="提交修改">
            </div></td>
            
          </tr>
        </table>
        </form>
		<?php }?>
		
		
		
		
        </div>
      </div>
    </div>
  </div>
</div>
<div id="botton"><div id="copyright"><table border="0" cellpadding="0" cellspacing="0" class="copy">
  <tr>
    <td>© COPYRIGHTS 2010 INC. APARTMENT STUDIO All rights reserved.</td>
  </tr>
</table>
</div></div>
</body>
</html>